﻿#ifndef SPEEDTESTWIDGET_H
#define SPEEDTESTWIDGET_H


#include <QWidget>
#include <QGridLayout>
#include <QPushButton>
#include <QSlider>
#include <QHBoxLayout>
#include "qcustomplot.h"
#include "define.h"
#include "capcontroldefine.h"
#include "logwidget.h"
#include "quiqss.h"
#include "parambasicwidget.h"


class QSpeedTestWidget : public QParamBasicWidget
{
    Q_OBJECT
public:
    explicit QSpeedTestWidget(QWidget *parent = nullptr);
    void InitUI();

    QWidget* createPIDWidget();

    QWidget* createTestWidget();


    QWidget* createParamWidget();

    void rcvFrameData(st_loopbackdata rcvdata);


    void plotPosData();
    void plotSpeedData();
    void plotCurrentData();


    void setPlotStyle(QCustomPlot* pPlot,QString xName,QString yName);

    void setButtonStyleSheet(QPushButton* pBtn);

//    void writeDataToFile(QString str);

//    void saveDataToFile();

signals:
    void signal_startTest(int i32Axis,int workmode,int data,int data1);


    void signal_framedata(QVariant var);

public slots:

    void onRcvPidParam(QVariant var);

    void onStartBtnClicked();

    void onStopBtnClicked();

    void onQueryParamBtnClicked();

    void onSetParamBtnClicked();

    void onSaveDataBtnClick();


private:
    QCustomPlot* _pSpeedPlot;//电流值反馈
    QCustomPlot* _pPosPlot;//电流值反馈
    QCustomPlot* _pCurreentPlot;//电流值反馈

    QLogWidget* _pLogWidget;

    QComboBox* _pSpeedForwardCombox;


    int _i32AixsNo;//轴编号

    QPushButton* _pQueryParamBtn;
    QPushButton* _pSetParamBtn;
    QLineEdit* _pKPEdit;
    QLineEdit* _pKIEdit;
    QLineEdit* _pSpeedForwardGainEdit;

    QLabel* _pShowPIDLabel;
    QLabel* _pShowStatusLabel;


    QCheckBox* _pSaveDataCheckBox;

    //参数设置界面
    QComboBox* _pSignalTypeComBox;
    QLineEdit* _pFreqEdit;
    QLineEdit* _pAmpEdit;


    QPushButton* _pStartBtn;
    QPushButton* _pStopBtn;

    QSlider* _pCurrentValueSlider;
    QLineEdit* _pCurrentValueEdit;

    QWidget* _pParamWidget;

    QTimer* _pPlotDataTimer;







    QVector<double> _xdatalist;
    QVector<double> _yposlist[2];
    QVector<double> _yspeedlist[2];

    QVector<double> _ycurrentlist[2];

    QVector<double> _ycurrentAlist;
    QVector<double> _ycurrentBlist;

    int _i32FrameCnt;


};

#endif // CURRENTADJWIDGET_H

